package priorities;

import general.ChannelAgent;

public class MiddleFirst extends PriorityManager{

	int numAgents;
	int lowPriorLow;
	int lowPriorHigh;
	int midPriorLow;
	int midPriorHigh;
	public MiddleFirst(int numAgnets) {
		this.numAgents = numAgnets;
		double bound1 = numAgents*0.15;
		double bound2 = numAgents*0.3;
		lowPriorLow = (int)bound1;
		lowPriorHigh = numAgents - lowPriorLow;
		midPriorLow = (int)bound2;
		midPriorHigh = numAgents - midPriorHigh;
	}
	
	@Override
	public void updatePriority(ChannelAgent agent) {
		byte id = agent.getAgentId();
		if (id<=lowPriorLow || id>=lowPriorHigh){
			agent.setPriority(Thread.MIN_PRIORITY);	
		} else if (id<=midPriorLow || id>=midPriorHigh){
			agent.setPriority(Thread.NORM_PRIORITY);
		} else {
			agent.setPriority(Thread.MAX_PRIORITY);
		}
		
		// TODO Auto-generated method stub
		
	}

}
